package com.yuwei.user

import androidx.lifecycle.MutableLiveData
import com.yuwei.base.BaseViewModel
import com.yuwei.http.ApiService
import com.yuwei.http.entity.UserEntity

import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class UserViewModel @Inject constructor(
    val  apiService: ApiService
): BaseViewModel() {
    val loginSuccess by lazy { MutableLiveData<UserEntity>() }
    fun login(username : String,password : String){
        executeNetwork({
            apiService.login(username,password)
        },loginSuccess::postValue)
    }
    val registerSuccess by lazy { MutableLiveData<UserEntity>() }
    fun register(username : String,password : String){
        executeNetwork({
            apiService.register(username,password)
        },registerSuccess::postValue)
    }
}